package com.loong.game2048.dao;

import com.loong.game2048.module.Comment;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CommentDao {

    @Insert("insert into comment (content,uid,parent_id,time,type) values(#{content},#{uId},#{parentId},#{time},#{type})")
    void addComment(Comment comment);

    @Select("select * from comment where parent_id = #{id}")
    @Results(id = "comment",value = {
            @Result(property = "uid",column = "u_id"),
            @Result(property = "parentId",column = "parent_id")
    })
    List<Comment> findByParentId(@Param("id") Integer id);

    @Select("select * from comment where id = #{id}")
    @ResultMap("comment")
    Comment findById(@Param("id") Integer id);

    @Insert("insert into comment (content,uid,parent_id,time,type,replier) values(#{content},#{uId},#{parentId},#{time},#{type},#{replier}) ")
    void reply(Comment comment);
}
